/**
 * 
 */
package com.cipe.cmrs.converter;

import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterRegistry;

import com.cipe.cmrs.bean.PaymentRequestLineItemBean;
import com.cipe.cmrs.model.Paymentrequestlineitem;

/**
 * @author Incepio
 * 
 */
public class PaymentlineitemToPaymentLineItemBean implements Converter<Paymentrequestlineitem, PaymentRequestLineItemBean> {

    private ConverterRegistry converterRegistry;

    /**
     * @param converterRegistry
     *            the converterRegistry to set
     */
    public void setConverterRegistry(ConverterRegistry converterRegistry) {
        this.converterRegistry = converterRegistry;
    }

    public void init() {
        converterRegistry.addConverter(this);
    }

    public PaymentRequestLineItemBean convert(Paymentrequestlineitem source) {
        PaymentRequestLineItemBean bean = null;
        if (source != null) {
            bean = new PaymentRequestLineItemBean();
            if (source.getAccountCode() != null) {
                bean.setAccountCodeId(source.getAccountCode().getId());
            }
            bean.setAmount(source.getPaymentrequestamount());
            bean.setPrevAmount(source.getPaymentrequestamount());
            if (source.getCipeproject() != null) {
                bean.setCipeProjectId(source.getCipeproject().getId());
            }
            bean.setId(source.getId());
            bean.setLineItemNumber(source.getLineitemnumber());
        }
        return bean;
    }
}
